package com.zlq.cn

import org.aspectj.util.FileUtil
import org.jsoup.Jsoup
import org.junit.Test
import org.openqa.selenium.WebDriver
import org.openqa.selenium.chrome.ChromeDriver
import org.openqa.selenium.chrome.ChromeOptions
import org.openqa.selenium.remote.CapabilityType
import java.io.File

fun main() {
    val baseManhua = "https://www.ohmanhua.com"
    val saveFile = File("F:\\java\\project\\zlqv1\\src\\main\\resources\\static\\test.html")
    System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe")
    val options = ChromeOptions()
//    options.addArguments("headless")
//    options.addArguments("no-sandbox")
    options.setCapability(CapabilityType.SUPPORTS_JAVASCRIPT,true)
    val driver: WebDriver = ChromeDriver(options)
    try {
        driver["https://www.vmall.com/product/10086009079805.html#2601010452802"]
//        driver["http://video.mtime.com/78066/?mid=267558"]
//        println("加载成功，开始等待")
//        Thread.sleep(5000L)
//        println("等待完毕")
//        FileUtil.writeAsString(File("D:\\development\\java\\project\\zlq\\src\\main\\resources\\static\\test2.html"), driver.pageSource)
        //            Jsoup.parse()
    } catch (e: Exception) {
        println(e)
    } finally {
//        driver.quit()
    }
//    val rootDocument = Jsoup.parse(FileUtil.readAsString(saveFile))
//    rootDocument.select("#myData.all_data_list .fed-part-rows li > a.fed-part-eone").forEach {
//        println(it.attr("title") + baseManhua + it.attr("href"))
//    }
}
